#!/bin/bash

if [ ! -n "${1}" ] || [ ! -n "${2}" ] || [ ! -n "${3}" ] || [ ! -n "${4}" ]; then
        echo "error! param need projectName,manager,develop,visitor"
        exit -1;
fi

projectName=${1}
managerParam=${2}
developParam=${3}
visitorParam=${4}

visitorSvn=`grep "^visitor=" /var3/svn/$projectName/conf/authz | awk '-F' '=' '{print $2}'`
developSvn=`grep "^develop=" /var3/svn/$projectName/conf/authz | awk '-F' '=' '{print $2}'`
managerSvn=`grep "^manager=" /var3/svn/$projectName/conf/authz | awk '-F' '=' '{print $2}'`

if [[ "$managerParam" != "$managerSvn" ]]; then
	sed -i "s/^manager=.*/manager=$managerParam/g" /var3/svn/$projectName/conf/authz
fi
if [[ "$developParam" != "$developSvn" ]]; then
	sed -i "s/^develop=.*/develop=$developParam/g" /var3/svn/$projectName/conf/authz
fi
if [[ "$visitorParam" != "$visitorSvn" ]]; then
	sed -i "s/^visitor=.*/visitor=$visitorParam/g" /var3/svn/$projectName/conf/authz
fi

echo "success"